package com.zw.admin.server.controller;

import com.aliyuncs.iot.model.v20180120.QueryProductResponse;
import com.aliyuncs.iot.model.v20180120.UpdateProductResponse;
import com.zw.admin.server.dao.SysChanDao;
import com.zw.admin.server.model.Dict;
import com.zw.admin.server.model.SysChan;
import com.zw.admin.server.page.table.PageTableHandler;
import com.zw.admin.server.page.table.PageTableHandler.CountHandler;
import com.zw.admin.server.page.table.PageTableHandler.ListHandler;
import com.zw.admin.server.page.table.PageTableRequest;
import com.zw.admin.server.page.table.PageTableResponse;
import com.zw.admin.server.service.ChanSerivce;
import com.zw.admin.server.service.SoilSerivce;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 土壤检测controller 我二姨
 * 这是我在码云上面添加的代码
 * 啊发顺丰
 *
 *
 */
@Api(tags = "土壤检测")
@RestController
@RequestMapping("/sysSoil")
public class SysSoilController {


    @Autowired
    private SoilSerivce soilSerivce;

    @GetMapping
    @ApiOperation(value = "列表")
    @RequiresPermissions("sys:chanpin:query")
    public PageTableResponse list(PageTableRequest request) {
        request.setCurrentPage(request.getOffset()/request.getLimit()+1);
        return new PageTableHandler(new CountHandler() {
            @Override
            public int count(PageTableRequest request) {
                return  soilSerivce.QueryProductList( request.getCurrentPage(), request.getLimit(),null).getTotal();
            }
        }, new ListHandler() {
            @Override
            public List list(PageTableRequest request) {
                return  soilSerivce.QueryProductList( request.getCurrentPage(), request.getLimit(),null).getList();
            }
        }).handle(request);
    }


	public static void main(String[] args) {
		String s = "123";
		String s2 = "123";
		String s1 = "123";
	}

}
